/**
 * @copyright Copyright (c) 2025 
 * CSG Digital Grid Technology (Guangdong) Co., Ltd.
 * @author xxxcsg
 * @brief 测试工具
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "eagle_eys_server.h"
// #include "hilog/log_c.h"

// #undef LOG_DOMAIN
// #undef LOG_TAG
// #define LOG_DOMAIN 0xD006666  // 标识业务领域，范围0xD000000~0xD0FFFFF
// #define LOG_TAG "HawkEye"

int get_module_mesg(ModuleMesg *mesg)
{
    // printf("get_module_mesg !!!\n");
    printf("ModuleMesg:%zu, int:%zu\n",sizeof(ModuleMesg),sizeof(mesg->baseInfo.bandWidth));

    // printf("debug:%d,info:%d,warn:%d,error:%d,fatal:%d\n",HiLogIsLoggable(LOG_DOMAIN,LOG_TAG,LOG_DEBUG),
    //     HiLogIsLoggable(LOG_DOMAIN,LOG_TAG,LOG_INFO),HiLogIsLoggable(LOG_DOMAIN,LOG_TAG,LOG_WARN),HiLogIsLoggable(LOG_DOMAIN,LOG_TAG,LOG_ERROR),
    //     HiLogIsLoggable(LOG_DOMAIN,LOG_TAG,LOG_FATAL));

    // HILOG_DEBUG(LOG_APP, "EagleEyeServerInit\n");
    // HILOG_INFO(LOG_APP, "EagleEyeServerInit\n");
    // HILOG_WARN(LOG_APP, "EagleEyeServerInit\n");
    // HILOG_ERROR(LOG_APP, "EagleEyeServerInit\n");
    // HILOG_FATAL(LOG_APP, "EagleEyeServerInit\n");
    
    // HiLogPrint(LOG_CORE, LOG_INFO, LOG_DOMAIN, LOG_TAG,"EagleEyeServerInit\n");
    // HiLogPrint(LOG_APP, LOG_INFO, LOG_DOMAIN, LOG_TAG,"EagleEyeServerInit\n");

    // OH_LOG_Print(LOG_APP,LOG_INFO,LOG_DOMAIN, LOG_TAG,"EagleEyeServerInit\n");

    if(!mesg)
    {
        // printf("mesg is NULL\n");
        return 1;
    }

    mesg->baseInfo.bandWidth = 100;
    strcpy(mesg->baseInfo.carrierInformation, "carrierInformation");
    strcpy(mesg->baseInfo.devName, "devName");
    strcpy(mesg->baseInfo.iccid, "iccid");
    strcpy(mesg->baseInfo.imei, "imei");
    strcpy(mesg->baseInfo.imsi, "imsi");
    strcpy(mesg->baseInfo.ip, "ip");
    strcpy(mesg->baseInfo.manufacture, "manufacture");
    strcpy(mesg->baseInfo.model, "model");
    strcpy(mesg->baseInfo.modelFirmwareVersion, "modelFirmwareVersion");
    strcpy(mesg->baseInfo.netType, "netType");
    strcpy(mesg->baseInfo.simId, "simId");
    strcpy(mesg->baseInfo.simStatus, "simStatus");
    
    mesg->interfaceTraffic.rxBytes = 100;
    mesg->interfaceTraffic.rxPackets = 100;
    mesg->interfaceTraffic.txBytes = 100;
    mesg->interfaceTraffic.txPackets = 100;
    strcpy(mesg->servingCell.downSpeed, "downSpeed");

    strcpy(mesg->servingCell.rsrp, "rsrp");
    strcpy(mesg->servingCell.rsrq, "rsrq");
    strcpy(mesg->servingCell.rssi, "rssi");
    strcpy(mesg->servingCell.sinr, "sinr");
    strcpy(mesg->servingCell.upSpeed, "upSpeed");
    strcpy(mesg->servingCell.speed, "speed");
    
    return 0;

}

int get_power_mesg(float *mesg)
{
    // printf("get_power_mesg !!!\n");

    if(!mesg)
    {
        // printf("mesg is NULL\n");
        return 1;
    }

    *mesg = 88.5;

    return 0;
}

int get_login_mesg(LoginMesg *mesg)
{
    if(!mesg)
    {
        // printf("mesg is NULL\n");
        return 1;
    }
    strcpy(mesg->loginTime,"1970-01-01 00:00:00");
    strcpy(mesg->user,"root");
    strcpy(mesg->srcIP,"192.168.1.1");
    strcpy(mesg->srcPort,"80");
    strcpy(mesg->dstIP,"192.168.1.2");
    strcpy(mesg->dstPort,"80");
    strcpy(mesg->cmd,"sshd");
    strcpy(mesg->cmdOutput,"Accepted");
    strcpy(mesg->opTime,"1970-01-01 00:00:00");

    return 0;
}

int main(int argc, char *argv[])
{
    int cnt = 0;
    BusinessHandle handle;
    handle.moduleMesgFunc = get_module_mesg;
    handle.powerMesgFunc = get_power_mesg;
    handle.loginMesgFunc = get_login_mesg;

    int ret = EagleEyeServerInit(&handle);
    printf("EagleEyeServerInit ret = %d\n",ret);
    if (ret) {
        printf("EagleEyeServerInit failed,ret = %d\n",ret);
        // HILOG_INFO(LOG_CORE, "EagleEyeServerInit failed\n");
        return -1;
    }

    while(1)
    {
        printf("EagleEyeServer test cnt:%d\n",cnt++);
        // HILOG_INFO(LOG_CORE, "cnt:%d init_test!!!!\n",cnt++);
        sleep(10000);

    }
    return 0;
}